<?php

/**
 * OrderProductSpecsModel 模型
 * Class OrderProductSpecsModel
 */
class OrderProductSpecsModel extends BaseModel
{

    public $tableName = "order_product_specs";
    public $errMsg = '';

    static private $_singleton;

    public function __construct()
    {
        parent::__construct($this->tableName);
    }

    static public function getSingleton()
    {
        if (!self::$_singleton) {
            self::$_singleton = new static();
        }

        return self::$_singleton;
    }

    public function add($data)
    {
        try {
            $selfModel = static::getSingleton();
            return $selfModel->insert([
                'order_id'      => $data['order_id'],
                'shop_id'    => $data['shop_id'],
                'product_id'       => $data['product_id'],
                'spec_id'  => $data['spec_id'],
                'buy_num'    => $data['buy_num'],
                'product_name' => $data['product_name'],
                'spec_name_full'     => $data['spec_name_full'],
                'unit_money'   => $data['unit_money'],
                'p_total_money'     => $data['p_total_money'],
                'cover_img'     => $data['cover_img'],
                'create_time'     => isset($data['create_time'])? $data['create_time']: time()
            ]);
        } catch (Exception $e) {
            $this->errMsg = $e->getMessage();
            return false;
        }
    }


}